package de.tabuma.soapforms.soapproject.logik;

import java.util.*;
import de.tabuma.soapforms.soapproject.entity.*;
import de.tabuma.customer.entity.*;
import de.tabuma.customer.logik.*;

/**
 *
 * @author alefen
 */
public class SoapProjectFacade {
    public static int create(SoapProject soapProject, String user) {
        return (int) PMF.doCreate(soapProject, user);
    }

    public static SoapProject get(int id) {
        return PMF.get(id, new SoapProject());
    }

    public static void update(SoapProject soapProject, String user) {
        PMF.doUpdate(soapProject, user);
    }

    public static void remove(int soapProjectId, String user) {
        SoapProject sp = get(soapProjectId);
        PMF.doRemove(sp, user);
    }

    public static List<SoapProject> getList(int customerId) {
        String keys[] = new String[1];
        keys[0] = "customerId";
        String values[] = new String[1];
        values[0] = ""+customerId;
        return PMF.get(keys, values, new SoapProject());
    }

    public static List<SoapProject> getList(String user) {
        List<Customer> cList = CustomerFacade.getCustomer(user);
        List<SoapProject> spList = new ArrayList<SoapProject>();
        for(int i=0;i<cList.size();i++) {
            spList.addAll(getList(cList.get(i).getId().intValue()));
        }
        return spList;
    }

    public static SoapProject getBySoapProjectId(int soapProjectId) {
        String keys[] = {};
        String values[] = {""+soapProjectId};
        List<SoapProject> spList = PMF.get(keys, values, new SoapProject());
        return spList.get(0);
    }
}
